<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib tagdir="/WEB-INF/tags/busterminal" prefix="bt"%>
<%@taglib uri="/WEB-INF/tags/tlds/Functions.tld" prefix="f"%>

<bt:IncludedFiles />
<table class="table table-striped table-bordered table-condensed">
    <caption>Bus list</caption>
    <thead>
        <tr>
            <th align="center">State number</th>
            <th align="center">Model name</th>
            <th align="center">Start year of exploitation</th>
            <th align="center">Purpose type</th>
        </tr>
    </thead>
    <tbody>
        <c:set var="user" scope="session" value="${userAuth}" />
        <c:set var="bus" scope="page" value="${bus}" /> 

        <tr>                
            <td><c:out value="${bus.getStateNumber()}" /></td>

            <c:if test="${f:isActionAllowed('bus.model.one.list', user.getRole())}">
                <c:url var="busModelURL" value="MainServlet">
                    <c:param name="action" value="bus.model.one.list" />
                    <c:param name="id" value="${bus.getBusModel().getId()}" />
                </c:url>
                <td><a href="${busModelURL}"><c:out value="${bus.getBusModel().getModelName()}" /></a></td>
            </c:if>

            <td><c:out value="${bus.getStartYearOfExploitation()}" /></td>

            <td><c:out value="${bus.getPurposeType()}" /></td>
                
            <c:if test="${f:isActionAllowed('bus.edit', user.getRole())}">
                <c:url var="editURL" value="MainServlet">
                    <c:param name="action" value="bus.edit" />
                    <c:param name="id" value="${bus.getId()}" />
                </c:url>
                <td nowrap width="48"><a class="btn btn-mini" href="${editURL}" id="show-edit-form" data-toggle="tab"><i class="icon-pencil icon-white"></i>&nbsp;Edit</a></td>
            </c:if>

            <c:if test="${f:isActionAllowed('bus.delete', user.getRole())}">
                <c:url var="deleteURL" value="MainServlet">
                    <c:param name="action" value="bus.delete" />
                    <c:param name="id" value="${bus.getId()}" />
                </c:url>
                <td nowrap width="62"><a class="btn btn-mini" id="show-delete-dialog" data-target="#delete-modal-window" data-toggle="modal" data-link="${deleteURL}" data-name="${bus.getStateNumber()}; ${bus.getBusModel().getModelName()}; ${bus.getStartYearOfExploitation()}; ${bus.getPurposeType()}"><i class="icon-trash icon-white"></i>&nbsp;Delete</a></td>
            </c:if>    
            </tr>
    </tbody>
</table>
<a class="btn btn-mini" href="MainServlet?action=main"><i icon-arrow-left class="icon-arrow-left icon-white"></i>&nbsp;Back</a>
<bt:DeleteDialog entity="bus" />